package Model;

import java.util.Date;
import java.util.ArrayList;
import java.text.SimpleDateFormat;

public class Task {

    private String name;
    private boolean done;
    private Date dueDate;
    private String type;

    /**
     * Constructor which creates a task with the following parameters
     *
     * @param iTaskName
     * @param iDueDate
     * @param iType
     */
    public Task(String iTaskName, Date iDueDate, String iType) {
        name = iTaskName;
        dueDate = iDueDate;
        type = iType;
        done = false;
    }

    /**
     * Copy constructor
     *
     * @param task
     */
    public Task(Task task) {
        this.name = task.getName();
        this.type = task.getType();
        this.dueDate = task.getDueDate();
    }

    /**
     * Sets this instances' name to empty string ("")
     *
     * @param name
     */
    public void removeName(String name) {
        this.name = "";
    }


    /**
     * Sets the status of the current task as done
     *
     * @param done
     */
    public void setDone(boolean done) {
        this.done = done;
    }

    /**
     * Set the name of the current task
     *
     * @param n
     */
    public void setName(String n) {
        this.name = n;
    }

    /**
     * Get the name of the current task
     *
     * @return
     */
    public String getName() {
        return this.name;
    }

    /**
     * Get the due date of the task
     *
     * @return
     */
    public Date getDueDate() {


        return dueDate;
    }

    /**
     * Get the status of the current task
     *
     * @return
     */
    public boolean getDone() {
        return this.done;
    }

    /**
     * Get the type of the current task
     *
     * @return
     */
    public String getType() {
        return type;
    }

    /**
     * Return the task information as a string.
     *
     * @return
     */
    public String toString() {
        String str = new String();
        str = "[";
        str += name;
        str += "|";
        str += dueDate;
        str += "|";
        str += type;
        str += "]";
        return str;
    }
    
    
    /**
     * Returns the due date for single tasks, 
     * Interval for periodic tasks
     * or "Complex" for complex tasks
     * @return
     */
    public String getDateString()
    {


    	if(null != dueDate)
    	{
	     	// Format date to yyyy-mm-dd
    		SimpleDateFormat wFormat = new SimpleDateFormat("yyyy-MM-dd");
    		return wFormat.format(dueDate);
    	}
    	else
    	{
    		return "No date";
    	}
    }
    
    /**
     * Returns the list of sub-tasks
     * @return
     */
    public ArrayList<Task> getSubtasks()
    {
    	return new ArrayList<Task>();    	
    }
    
 

}
